part of '../repository.dart';

const _kGooglePlayPurchasedSubscriptionActiveStatusValue = 'active';
const _kGooglePlayPurchasedSubscriptionExpiredStatusValue = 'expired';
const _kGooglePlayPurchasedSubscriptionPausedPeriodStatusValue = 'paused';
const _kGooglePlayPurchasedSubscriptionRevokedStatusValue = 'revoked';

class _GooglePlayPurchasedSubscriptionStatusDto extends Equatable {
  const _GooglePlayPurchasedSubscriptionStatusDto._internal({
    required this.statusString,
  });

  final String statusString;

  @override
  List<Object?> get props {
    return [
      statusString,
    ];
  }

  factory _GooglePlayPurchasedSubscriptionStatusDto.fromString(String statusString) {
    return _GooglePlayPurchasedSubscriptionStatusDto._internal(
      statusString: statusString,
    );
  }

  GooglePlayPurchasedSubscriptionStatus toEntity() {
    if (statusString == _kGooglePlayPurchasedSubscriptionActiveStatusValue) {
      return GooglePlayPurchasedSubscriptionStatus.active;
    }

    if (statusString == _kGooglePlayPurchasedSubscriptionExpiredStatusValue) {
      return GooglePlayPurchasedSubscriptionStatus.expired;
    }

    if (statusString == _kGooglePlayPurchasedSubscriptionPausedPeriodStatusValue) {
      return GooglePlayPurchasedSubscriptionStatus.paused;
    }

    if (statusString == _kGooglePlayPurchasedSubscriptionRevokedStatusValue) {
      return GooglePlayPurchasedSubscriptionStatus.revoked;
    }

    throw UnimplementedError();
  }
}
